<template>
  <view class="">
    <view v-for="(item, i) in list" :key="i" class="bg-white mt-12">
      <view class="flex py-10 px-14 hair--b">
        <view class="file-logo flex-ca text-12">{{ item.object_logo || item.file_logo }}</view>
        <view class="flex-1 leading-20 ellipsis-2">
          {{ item.object_name || item.file_name }}
        </view>
      </view>
      <view class="py-10 px-14 flex-ba">
        <view class="leading-16 text-12 text-info"><text v-if="timeLabel">{{ timeLabel }}：</text>{{ $f.formatDate(item.create_time) }}</view>
        <slot :object-id="item.object_id" />
      </view>
    </view>
    <uni-load-more :status="$f.getLoading(loading)" />
  </view>
</template>

<script>
export default {
  props: {
    api: String,
    timeLabel: String,
    param: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      list: [],
      page: 1,
      loading: 0,
      limit: 10
    }
  },
  methods: {
    listInit() {
      this.list = []
      this.page = 1
      this.loading = 0
      this.getList()
    },
    getList() {
      if (this.loading) return
      this.loading = 1
      this.$f.post(this.api, {
        ...this.param,
        page: this.page,
        limit: this.limit
      }).then(res => {
        this.loading = this.limit > res.data.length ? 2 : 0
        if (res.data.length) {
          this.list = [...this.list, ...res.data]
          this.page += 1
        }
      })
    }
  }
}
</script>

<style lang="scss">
.file-logo {
	width: 80rpx;
	height: 80rpx;
	margin-right: 16rpx;
	background-color: #E7ECF2;
}
</style>
